<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" name="viewport">
  <meta content="ie=edge" http-equiv="X-UA-Compatible">
  <title>Login</title>
  <script src="lib/jquery.min.js"></script>
  <script>
  $(function () {
    $('#login').on('click', function () {
      $('#errorMessage').hide();
      $.ajax({
        method: 'post',
        url: '/api/rest/post/userLoginUIService/login',
        data: JSON.stringify([$('#username').val(), $('#password').val()]),
        contentType: 'application/json',
        dataType: 'json',
        success: function (d) {
          if (d.code === 0 || d.code === '0') {
            window.location.href = '/index.html';
          } else {
            $('#errorMessage').text(d.message).show();
          }
        }
      });
    });
  });
  </script>
</head>
<body>

<div style="border: 1px solid red">
  <div id="errorMessage" style="padding: 10px; color: red; font-size: 12px; display: none"></div>
  <div style="padding: 10px">
    <label for="username">用户名</label>
    <input id="username" type="text">
  </div>
  <div style="padding: 10px">
    <label for="password">密码</label>
    <input id="password" type="password">
  </div>
  <div style="padding: 10px">
    <button id="login">登录</button>
  </div>
</div>
</body>
</html>
